;; supercollider/server-current.scm - (c) rohan drape, 2003-2005

;; The current server parameter.  All user level server operations are
;; on the 'current-server'.

(define-parameter current-server (server-local))

;; Latency.

(define (server-latency)
  (server_-latency (current-server)))

(define (set-server-latency! value)
  (set-server_-latency! (current-server) value))

;; Address.

(define (server-network-address)
  (server_-address (current-server)))

(define (server-host-address)
  (network-address-host-address (server-network-address)))

(define (server-host-name)
  (host-address->host-name (server-host-address)))

(define (server-port-number)
  (network-address-port-number (server-network-address)))

;; The total number of input and output busses.  This value is the
;; index to the first private bus.

(define (server-first-private-bus)
  (+ (server-option 'number-of-input-bus-channels)
     (server-option 'number-of-output-bus-channels)))

;; Send '/g_freeAll' message to the root node of `server'.  The server
;; will send notifications for all removed nodes if requested.

(define (server-free-all)
  (-> "/g_freeAll" 0)
;;  (-> "/clearSched") - ERROR IN PLT...
  (-> "/g_new" 1))

;; Set notification status for `server'.

(defineK (server-notify (status #t) (synchronous #t))
  (server-request* synchronous "/done" (list "/notify" status)))

